package com.dce.dev.api.controller.delivery.invoice;

import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.dce.dev.api.common.tools.JsonFileTool;
import com.dce.dev.api.common.tools.json.JsonUtils;
import com.dce.dev.api.dto.base.ResultDTO;
import com.dce.dev.api.dto.delivery.AddDeliveryInvoiceTitleReqDTO;
import com.dce.dev.api.dto.delivery.DeliveryInvoiceDetailDTO;
import com.dce.dev.api.dto.delivery.DeliveryInvoiceDetailReqDTO;
import com.dce.dev.api.dto.delivery.InvoiceDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 交割信息接口
 */
@RestController
@RequestMapping("/delivery/invoice/")
@Api(value = "后台服务--发票功能", description = "后台服务--发票功能")
public class InvoiceInfoController {
	
	@RequestMapping(value = "/getDeliveryInvoiceList", method = RequestMethod.POST)
    @ApiOperation(value = "获取发票列表")
    public ResultDTO<List<InvoiceDTO>> getDeliveryInvoiceList() {
        String strJson = JsonFileTool.readJSON("delivery/invoicelist.json");
        final List<InvoiceDTO> dtoRtn = JsonUtils.jsonToPojo(strJson, List.class);
        return ResultDTO.success(dtoRtn,"列表获取成功");
    }
	
	@RequestMapping(value = "/getDeliveryInvoiceDetail", method = RequestMethod.POST)
	@ApiOperation(value = "获取发票详情")
	public ResultDTO<DeliveryInvoiceDetailDTO> getDeliveryInvoiceDetail(@RequestBody DeliveryInvoiceDetailReqDTO dtoReq) {
		String strJson = JsonFileTool.readJSON("delivery/deliveryinvoicedetail.json");
		final DeliveryInvoiceDetailDTO dtoRtn = JsonUtils.jsonToPojo(strJson, DeliveryInvoiceDetailDTO.class);
		return ResultDTO.success(dtoRtn, "发票详情获取成功");
	}
	
	@RequestMapping(value = "/addDeliveryInvoiceTitle", method = RequestMethod.POST)
	@ApiOperation(value = "新增发票抬头")
	public ResultDTO<Void> addDeliveryInvoiceTitle(AddDeliveryInvoiceTitleReqDTO dto) {
		// String strJson =
		// JsonFileTool.readJSON("basebusiness/delivery/deliveryprogress.json");
		// final List<DeliveryProgressDTO> dtoRtn =
		// JsonUtils.jsonToPojo(strJson, List.class);
		return ResultDTO.success("保存成功");
	}
	
	@RequestMapping(value = "/modifyDeliveryInvoiceTitle", method = RequestMethod.POST)
	@ApiOperation(value = "修改发票抬头")
	public ResultDTO<DeliveryInvoiceDetailDTO> modifyDeliveryInvoiceTitle(AddDeliveryInvoiceTitleReqDTO dto) {
		String strJson = JsonFileTool.readJSON("delivery/deliveryinvoicedetail.json");
		final DeliveryInvoiceDetailDTO dtoRtn = JsonUtils.jsonToPojo(strJson, DeliveryInvoiceDetailDTO.class);
		return ResultDTO.success(dtoRtn, "发票详情修改成功");
	}
	
	@RequestMapping(value = "/deleteDeliveryInvoiceTitle", method = RequestMethod.POST)
	@ApiOperation(value = "删除发票抬头")
	public ResultDTO<Void> deleteDeliveryInvoiceTitle(@RequestBody DeliveryInvoiceDetailReqDTO dtoReq) {
		// String strJson =
		// JsonFileTool.readJSON("basebusiness/delivery/deliveryprogress.json");
		// final List<DeliveryProgressDTO> dtoRtn =
		// JsonUtils.jsonToPojo(strJson, List.class);
		return ResultDTO.success("删除发票抬头成功");
	}
	
}
